<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>个人中心</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .profile-container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .profile-header {
            text-align: center;
            margin-bottom: 20px;
            padding-bottom: 20px;
            border-bottom: 1px solid #eee;
        }
        .avatar {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: #4CAF50;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            margin: 0 auto 10px;
        }
        .info-section {
            margin-bottom: 20px;
        }
        .info-row {
            display: flex;
            margin-bottom: 10px;
            padding: 10px;
            background-color: #f9f9f9;
            border-radius: 4px;
        }
        .info-label {
            font-weight: bold;
            width: 120px;
        }
        .info-value {
            flex: 1;
        }
        .action-buttons {
            margin-top: 20px;
            text-align: center;
        }
        .btn {
            padding: 8px 16px;
            margin: 0 5px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
        }
        .btn-edit {
            background-color: #4CAF50;
            color: white;
        }
        .btn-change-pwd {
            background-color: #2196F3;
            color: white;
        }
        .btn-back {
            background-color: #f44336;
            color: white;
        }
        .bmi-indicator {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 12px;
            margin-left: 10px;
        }
        .bmi-normal {
            background-color: #4CAF50;
            color: white;
        }
        .bmi-warning {
            background-color: #FFC107;
            color: black;
        }
        .bmi-danger {
            background-color: #f44336;
            color: white;
        }
    </style>
</head>
<body>
<div class="profile-container">
    <div class="profile-header">
        <div class="avatar">${user.username.charAt(0)}</div>
        <h2>${user.username}的个人中心</h2>
    </div>

    <div class="info-section">
        <h3>基本信息</h3>
        <div class="info-row">
            <div class="info-label">用户ID：</div>
            <div class="info-value">${user.userid}</div>
        </div>
        <div class="info-row">
            <div class="info-label">用户名：</div>
            <div class="info-value">${user.username}</div>
        </div>
        <div class="info-row">
            <div class="info-label">电话：</div>
            <div class="info-value">${user.phone}</div>
        </div>
        <div class="info-row">
            <div class="info-label">性别：</div>
            <div class="info-value">${user.sex}</div>
        </div>
        <div class="info-row">
            <div class="info-label">年龄：</div>
            <div class="info-value">${user.age}岁</div>
        </div>
    </div>

    <div class="info-section">
        <h3>健康数据</h3>
        <div class="info-row">
            <div class="info-label">身高：</div>
            <div class="info-value">${user.height} cm</div>
        </div>
        <div class="info-row">
            <div class="info-label">体重：</div>
            <div class="info-value">${user.weight} kg</div>
        </div>
        <div class="info-row">
            <div class="info-label">BMI：</div>
            <div class="info-value">
                ${user.bmi}
                <c:choose>
                    <c:when test="${user.bmi < 18.5}">
                        <span class="bmi-indicator bmi-warning">偏瘦</span>
                    </c:when>
                    <c:when test="${user.bmi >= 18.5 && user.bmi < 24}">
                        <span class="bmi-indicator bmi-normal">正常</span>
                    </c:when>
                    <c:when test="${user.bmi >= 24 && user.bmi < 28}">
                        <span class="bmi-indicator bmi-warning">超重</span>
                    </c:when>
                    <c:otherwise>
                        <span class="bmi-indicator bmi-danger">肥胖</span>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
        <div class="info-row">
            <div class="info-label">注册时间：</div>
            <div class="info-value">
                <fmt:formatDate value="${user.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </div>
        </div>
    </div>

    <div class="action-buttons">
        <a href="${pageContext.request.contextPath}/user/edit/${user.userid}" class="btn btn-edit">编辑信息</a>
        <a href="${pageContext.request.contextPath}/profile/change-password" class="btn btn-change-pwd">修改密码</a>
        <a href="${pageContext.request.contextPath}/user/list" class="btn btn-back">返回列表</a>
    </div>
</div>
</body>
</html>